﻿using System;
using System.Collections.Generic;
using System.Text;

namespace DBUtil.Expressions
{
    /// <summary>
    /// 数据库日期时间运算符
    /// </summary>
    public abstract class DateTimeExpression
    {
        /// <summary>
        /// 默认的日期时间类型
        /// </summary>
        public virtual string DefaultDateTimeType => "datetime2";

        /// <summary>
        /// 获取当前时间
        /// </summary>
        public abstract string Current { get; }

        /// <summary>
        /// 当前时间加上指定的天数
        /// </summary>
        /// <param name="day">加上的天数</param>
        public abstract string GetCurrentAddDay(long day);

        /// <summary>
        /// 当前时间加上指定的小时数
        /// </summary>
        /// <param name="hour">加上的小时数</param>
        public abstract string GetCurrentAddHour(long hour);

        /// <summary>
        /// 当前时间加上指定的分钟数
        /// </summary>
        /// <param name="minute">加上的分钟数</param>
        /// <returns></returns>
        public abstract string GetCurrentAddMinute(long minute);

        /// <summary>
        /// 当前时间加上指定的秒数
        /// </summary>
        /// <param name="second">加上的秒数</param>
        /// <returns></returns>
        public abstract string GetCurrentAddSecond(long second);

        /// <summary>
        /// 获取时间的字符串表示
        /// </summary>
        /// <param name="datetime">指定的时间</param>
        /// <returns></returns>
        public abstract string GetStringInSql(DateTime datetime);

        /// <summary>
        /// 获取日期时间的过滤条件
        /// </summary>
        /// <param name="colName">列名</param>
        /// <param name="start">开始时间</param>
        /// <param name="end">结束时间</param>
        /// <param name="includeStart">是否包含开始时间</param>
        /// <param name="includeEnd">是否包含结束时间</param>
        /// <returns></returns>
        public abstract string GetFilterString(string colName, DateTime? start, DateTime? end, bool includeStart = true, bool includeEnd = false);
    }
}
